<?php
/* SVN FILE: $Id: assessment_quality_attribute.php 21 2009-09-28 02:47:50Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-09-28 02:47:50 +0000 (Mon, 28 Sep 2009) $
 * $Revision: 21 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/models/assessment_quality_attribute.php $
 */
class AssessmentQualityAttribute extends AppModel {
  var $name = 'AssessmentQualityAttribute';
  var $belongsTo = array('Assessment','QualityAttribute','LikertResult');
  var $validate = array(
    'comments' => array(
		  'rule' => array('minLength',1)),

    'likert_result_id' => array(
      'rule' => 'numeric',
      'allowEmpty' => false,
      'message' => 'Please indicate your level of agreement with the statement.'));  
  
  function getForAssessment($assessment_id)
  {
    return $this->query("SELECT aq.id,q.name,q.description,l.name,aq.comments " .
                        "FROM assessment_quality_attributes aq " .
                        "JOIN quality_attributes q ON q.id = aq.quality_attribute_id " .
                        "LEFT OUTER JOIN likert_results l ON l.id = aq.likert_result_id " . 
                        "WHERE aq.assessment_id = {$assessment_id}");
  }
  
  function getForId($id)
  {
    return $this->query("SELECT a.submission_id,a.id,aq.id,q.name,q.description,l.name,aq.comments " .
                        "FROM assessment_quality_attributes aq " .
                        "JOIN assessments a ON a.id = aq.assessment_id " .
                        "JOIN quality_attributes q ON q.id = aq.quality_attribute_id " .
                        "LEFT OUTER JOIN likert_results l ON l.id = aq.likert_result_id " . 
                        "WHERE aq.id = {$id}");
  }
}
?>